package com.ruoyi.enterprise.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.enterprise.domain.SInterview;
import com.ruoyi.enterprise.service.ISInterviewService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 求职信息Controller
 *
 * @author jeffery
 * @date 2021-09-03
 */
@RestController
@RequestMapping("/enterprise/interview")
public class SInterviewController extends BaseController
{
    @Autowired
    private ISInterviewService sInterviewService;

    /**
     * 查询求职信息列表
     */
    @PreAuthorize("@ss.hasPermi('enterprise:interview:list')")
    @GetMapping("/list")
    public TableDataInfo list(SInterview sInterview)
    {
        startPage();
        List<SInterview> list = sInterviewService.selectSInterviewList(sInterview);
        return getDataTable(list);
    }

    /**
     * 导出求职信息列表
     */
    @PreAuthorize("@ss.hasPermi('enterprise:interview:export')")
    @Log(title = "求职信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SInterview sInterview)
    {
        List<SInterview> list = sInterviewService.selectSInterviewList(sInterview);
        ExcelUtil<SInterview> util = new ExcelUtil<SInterview>(SInterview.class);
        return util.exportExcel(list, "求职信息数据");
    }

    /**
     * 获取求职信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('enterprise:interview:query')")
    @GetMapping(value = "/{interviewId}")
    public AjaxResult getInfo(@PathVariable("interviewId") Long interviewId)
    {
        return AjaxResult.success(sInterviewService.selectSInterviewByInterviewId(interviewId));
    }

    /**
     * 新增求职信息
     */
    @PreAuthorize("@ss.hasPermi('enterprise:interview:add')")
    @Log(title = "求职信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SInterview sInterview)
    {
        return toAjax(sInterviewService.insertSInterview(sInterview));
    }

    /**
     * 修改求职信息
     */
    @PreAuthorize("@ss.hasPermi('enterprise:interview:edit')")
    @Log(title = "求职信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SInterview sInterview)
    {
        return toAjax(sInterviewService.updateSInterview(sInterview));
    }

    /**
     * 删除求职信息
     */
    @PreAuthorize("@ss.hasPermi('enterprise:interview:remove')")
    @Log(title = "求职信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{interviewIds}")
    public AjaxResult remove(@PathVariable Long[] interviewIds)
    {
        return toAjax(sInterviewService.deleteSInterviewByInterviewIds(interviewIds));
    }
}